< previous page page_276 next page >

Page 276
Animating Program Icons
A form may not always be visible, but its icon is always present in the task bar. Because a form's icon is always visible yet never gets in the way of other programs, it makes sense to put information there.
As you start more and more tasks, the task bar becomes crowded. Each time you start a new application, Windows adds the application's icon and caption text to the task bar. If there is not enough room in the task bar for the new application, Windows shrinks all of the other items to make room. That reduces the amount of text each item can display.
Because the shrinking occurs on the right side and the icons are displayed on the left, the icons usually remain visible. Eventually, if you start enough applications, the text will be completely hidden, but the icons will still be there.
This arrangement makes task bar icons an ideal place to put information that you want to be able to find easily and quickly. Of course, the icons in Windows 95 are very small, so you cannot put much information there. Still, there are times when changing or animating a task bar icon can be useful.
To change the picture displayed in a task bar icon, set the form's Icon property to an object containing an icon property. For example, if you have an image control named imgWaiting that contains an icon, you can display that icon in the task bar with the following code.
e10a6a0a59f035e870d90cca05b85fce.gif
frmSearch.Icon = imgWaiting.Picture
You can also set the icon using the LoadPicture function, as in:
e10a6a0a59f035e870d90cca05b85fce.gif
frmSearch.Icon = LoadPicture("C:\Search\Waiting.ico")
Once you know how to change a program's icon, you can animate it by rapidly cycling through a series of icons. You can use all the techniques described earlier for bitmap animation. You can regulate the speed of display using a timer control, or you can write your own routines to keep time using the Timer function or the GetTickCount API function.
Example program IconAnim displays an animated icon. Click the option buttons to see different animations.
There are a few very important considerations you should keep in mind when you animate an application's icon. First, the icons in the task bar are very small. If you assign a larger icon to a form's Icon property, Windows shrinks the icon to fit in the task bar. When it is shrunk, the icon loses some of its resolution and may become meaningless. To ensure that your icons are meaningful, always test them and see what they look like in the task bar.
Second, if you change the icon displayed by an application, finding the application in the task bar may be difficult. If the icon could hold any of a dozen different shapes, the user will need to look carefully to find the application's icon. To make finding an applica-

 
< previous page page_276 next page >